import { onMounted, ref } from 'vue';
import {usedarkStore} from '@/stone/index'
export default function(){
    const darkStore=usedarkStore();
    let html=document.documentElement
    let dark=ref<boolean>(localStorage.getItem("dark")=="1"?true:false)
    onMounted(()=>{
        dark.value?html.className = 'dark' : html.className = '';
        darkStore.dark=dark.value
    })

    const changeDark=()=>{
        dark.value=!dark.value
        localStorage.setItem("dark",dark.value?"1":"0")
        dark.value?html.className = 'dark' : html.className = '';
        darkStore.dark=dark.value
    }

    return {dark,changeDark}
}